<template>
  <div>
  
  
    <el-table :data="tableData" style="width: 100%;margin-top:20px;">
      <el-table-column align="center" label="系统名称" prop="systemName"></el-table-column>
      <!-- <el-table-column align="center" label="流程ID" prop="procedefId"></el-table-column> -->
      <el-table-column align="center" label="事项名称" prop="name"></el-table-column>
      <el-table-column align="center" label="事项ID" prop="id"></el-table-column>
      <el-table-column align="center" label="版本号" prop="versionNumber"></el-table-column>
      <el-table-column align="center" label="状态">
        <template slot-scope="scope">
          <span class="success" v-if="scope.row.isUse == 1">
            {{scope.row.isUse | systemType}}
          </span>
          <span class="error" v-else>
            {{scope.row.isUse | systemType}}
          </span>
        </template>
      </el-table-column>
      <!-- <el-table-column align="center" label="流程名称" prop="procedefName"></el-table-column> -->
      <el-table-column align="center" label="操作">
        <template slot-scope="scope">
          <!-- <el-button size="small" type="primary" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button> -->
          <el-button size="small" type="primary" @click="handleEdit(scope.$index, scope.row)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="page">
      <el-pagination
        @current-change="pageChange"
        :page-size="pageSize"
        layout="prev, pager, next"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [],
      total: 0,
      pageSize: 10,
      isShowTable: false,
      activeName: "",
      systemName: ""
    };
  },
  created() {
    this.init(1);
  },
  methods: {
    init(pageNum) {
      this.$post("/proceeding/list", {
        pageNum: pageNum,
        pageSize: this.pageSize,
        hasInited: '',
        // procedefId:this.$route.query.procedefId,
        systemCode:this.$route.query.systemCode,
        proceedingId:this.$route.query.itemId,
      }).then(data => {
        this.tableData = data.result.dataList;
        this.total = Number(data.result.totalCount)
      });
    },
    handleEdit(index, row) {
      this.$router.push({
        path: "/home/itemConfig",
        query: {
          sysName: this.$route.query.systemCode,
          itemId: row.id,
          type: "edit", 
          itemName: row.name,
          InsuranceName: this.$route.query.sysName,
          versionNumber:row.versionNumber,
          procedefId:this.$route.query.procedefId,
          procedefName:row.procedefName,
          proceedingProcedefId:row.proceedingProcedefId
        }
      });
    },
    sysTemChange(val) {
      this.systemName = val;
    },
    handleClick(tab, event) {
      
      if (tab.label == "医保") {
        this.tableData = [];
      }
      if (tab.label == "社保") {
        this.init();
      }
    },
    detailsClick(){

    },
    handleDelete(index, row) {
      this.$confirm("确认删除吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$post("/proceeding/delete", {
            id: row.id
          }).then(data => {
            this.tableData.splice(index, 1);
            this.$message({
              type: "success",
              message: data.resultDes
            });
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },

    pageChange(val) {
      console.log(val);
      
      this.init(val);
    },
    
  }
};
</script>

<style scoped lang="css">
.page {
  display: flex;
  width: 100%;
  justify-content: center;
 margin-top: 30px;
}
.success{
  color: #67C23A
}
.error{
  color: #F56C6C
}
</style>
